<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="6" :sm="8">
            <a-form-item :label="$t('m.system.datalog.entity.dataTable')">
              <a-input placeholder="" v-model="queryParam.dataTable"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item :label="$t('m.system.datalog.entity.dataId')">
              <a-input placeholder="" v-model="queryParam.dataId"></a-input>
            </a-form-item>
          </a-col>

          <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
               <a-col :md="6" :sm="24">
                  <a-button type="primary" @click="searchQuery" icon="search">{{ $t('m.common.button.query') }}</a-button>
                  <a-button type="default" style="margin-left: 8px" @click="searchReset"  icon="reload" >{{ $t('m.common.button.reset') }}</a-button>
               </a-col>
            </span>
        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleCompare()" type="primary" icon="plus">{{$t('m.system.datalog.other.dataCompare')}}</a-button>
    </div>

    <!--table区 -->
    <div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys,onChange: onSelectChange}"
        @change="handleTableChange"
      >
        <span slot="versionSlot" slot-scope="text">
            <a-tag style="width:50px;" color="blue">
              {{ text }}
            </a-tag>
        </span>
      </a-table>
    </div>
    <data-log-modal ref="modalForm" @ok="modalFormOk"></data-log-modal>
  </a-card>
</template>

<script>

  import DataLogModal from './modules/DataLogModal'
  import {YcListMixin} from '@/mixins/YcListMixin'
  import YchConstant from "@/api/YchConstant";

  export default {
    name: 'DataLogList',
    mixins: [YcListMixin],
    components: {
      DataLogModal,
    },
    data() {
      return {
        description: '数据日志管理页面',
        //表头
        columns: [
          {
            title: this.$t('m.system.datalog.entity.dataTable'),
            align: 'center',
            dataIndex: 'dataTable',
            width: "100px"
          }, {
            title: this.$t('m.system.datalog.entity.dataId'),
            align: 'center',
            dataIndex: 'dataId',
            width: "200px"
          }, {
            title: this.$t('m.system.datalog.entity.dataVersion'),
            align: 'center',
            dataIndex: 'dataVersion',
            width: "50px",
            scopedSlots: { customRender: 'versionSlot' }
          },{
            title: this.$t('m.system.datalog.entity.createBy'),
            align: 'center',
            dataIndex: 'createBy',
            width: "80px"
          },, {
            title: this.$t('m.system.datalog.entity.createTime'),
            align: 'center',
            dataIndex: 'createTime',
            width: "120px"
          },
        ],
        url: {
          list: YchConstant.PREFIX_SYSTEM + "/dataLog/list",
        },
      }
    },
    methods: {
      handleCompare: function () {
        if (!this.selectionRows || this.selectionRows.length != 2) {
          this.openNotifIcon(this.$t('m.system.datalog.other.dataCompare_tip1'));
          return false;
        } else if (this.selectionRows[0].dataId != this.selectionRows[1].dataId) {
          this.openNotifIcon(this.$t('m.system.datalog.other.dataCompare_tip2'));
          return false;
        } else {
          this.$refs.modalForm.addModal(this.selectionRows);
          this.$refs.modalForm.title = this.$t('m.system.datalog.other.dataCompare');
        }
      },
      openNotifIcon(msg) {
        this.messageUtil.warning(msg, this.$t('m.common.label.prompt'))
      },
    }

  }

</script>
<style lang="less" scoped>
</style>
